package org.example.DesignPatterns.State;

/**
 * @description:
 * @author: farprt
 * @create: 2022-09-23 18:23
 **/
public class Red implements State{


    @Override
    public void switchToGreen(TrafficLight trafficLight) {
        System.out.println("Error,红灯不能切换为绿灯");
    }

    @Override
    public void switchToYellow(TrafficLight trafficLight) {
        trafficLight.setState(new Yellow());
        System.out.println("黄灯亮起");
    }

    @Override
    public void switchToRed(TrafficLight trafficLight) {
        System.out.println("Error,已是红灯，无需切换");
    }
}